package org.linlinjava.litemall.wx.listener;

import org.linlinjava.litemall.core.payment.paypal.service.impl.GoodsPaypalServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * 成员侦听器
 *
 * @author yliyun
 * @date 2022/10/28
 */
@Component
public class MemberListener {
    /**
     * 贝宝服务
     */
    @Autowired
    private GoodsPaypalServiceImpl paypalService;

    /**
     * 侦听器
     *
     * @param memberEvent 会员活动
     */
    @Async
    @EventListener(MemberListener.class)
    public void listener(MemberEvent memberEvent){
//                //获取订单实际支付金额 赠送用户积分
        Integer orderId = (Integer) memberEvent.getSource();
        //赠送积分
//        paypalService.presentPoint(orderId);
        //用户 等级会员的提升
        paypalService.upgradeUserLevel(orderId);
    }
}
